/*
 * @Description: 操作邮箱
 * @Author: chenjiaxin
 * @Date: 2022-01-04 17:59:10
 * @LastEditTime: 2022-01-05 06:32:27
 * @FilePath: \novel-serve\src\utils\email.js
 */
const nodemailer = require("nodemailer");
const { EMAIL_ACCOUNT, EMAIL_PASS } = require("../app/config");


class Email {
  constructor () {
    this.config = {
      host: 'smtp.qq.com',
      port: 587, // 587
      secure: false, // true for 465, false for other ports  
      auth: {
        user: EMAIL_ACCOUNT, // 发件人
        pass: EMAIL_PASS // 密钥
      }
    }
  }
  async transporter () {
    console.log("===输出====", );
    console.log("===输出====", this.config);
    return nodemailer.createTransport(this.config);
  }
  
  async getCode () {
    return Math.random().toString().substring(2,6);
  }
}

module.exports = new Email();

